package com.wmyg.antifake.gs1.ns2;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.dom4j.Attribute;
import org.dom4j.Element;

import java.util.List;

/**
 * @program: antifake
 * @description: 特殊字符串属性
 * @author: wong
 * @create: 19-4-23
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SpecialString {

    private String languageCode;

    private String codeListVersion;

    private String string;

    public SpecialString(Element element) {
        List<Attribute> attributes = element.attributes();
        for (Attribute attribute :
                attributes) {
            switch (attribute.getName()) {
                case "languageCode":
                    this.languageCode = attribute.getValue();
                    break;
                case "codeListVersion":
                    this.codeListVersion = attribute.getValue();
                    break;
                default:
            }
        }
        this.string = element.getText();
    }

}
